package com.lanxin.zc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lanxin.zc.entity.ZcAssetmoveapply;
import com.lanxin.zc.mapper.ZcAssetmoveapplyMapper;
import com.lanxin.zc.mapper.ZcAssetmovelogMapper;
import com.lanxin.zc.service.IZcAssetmoveapplyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanxin.zc.vo.AllzcassetmoveapplyVo;
import com.lanxin.zc.vo.AllzcassetpurchaseapplyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2025-07-16
 */
@Service
public class ZcAssetmoveapplyServiceImpl extends ServiceImpl<ZcAssetmoveapplyMapper, ZcAssetmoveapply> implements IZcAssetmoveapplyService {

    @Autowired
    private ZcAssetmoveapplyMapper assetmoveapplyMapper;
    @Autowired
    private ZcAssetmovelogMapper assetmovelogMapper;

    //根据部门获取待审批申请
    @Override
    public List<ZcAssetmoveapply> getAssetmoveapplyByDept(Integer deptId) {
        QueryWrapper<ZcAssetmoveapply> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deptid", deptId);
        queryWrapper.eq("status", "O");
        return assetmoveapplyMapper.selectList(queryWrapper);
    }

    //根据部门获取所有的资产移动申请
    @Override
    public List<ZcAssetmoveapply> listAssetmoveapplyByDept(Integer deptId) {
        QueryWrapper<ZcAssetmoveapply> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deptid", deptId);
        return assetmoveapplyMapper.selectList(queryWrapper);
    }

    //修改资产移动申请的审批状态
    @Override
    public int updateAssetMoveStatus(Integer oid, String status) {
        Map<String,Object> map = new HashMap<>();
        map.put("oid",oid);
        map.put("status",status);
        return assetmoveapplyMapper.updateAssetMoveStatus(map);
    }

    @Override
    public Page<AllzcassetmoveapplyVo> selectzcassetmoveList(Integer page, Integer pageSize, String docNo, String empName, String submitDate, String status) {

        PageHelper.startPage(page, pageSize);

        List<AllzcassetmoveapplyVo> allzcassetmoveapplyVos=assetmovelogMapper.selectzcassetmoveList(docNo, empName, submitDate, status);
        return (Page<AllzcassetmoveapplyVo>) allzcassetmoveapplyVos;

    }

    @Override
    public Page<AllzcassetmoveapplyVo> selectmyzcassetmoveList(Integer page, Integer pageSize, String docNo, String submitDate, String status, Integer proposer) {
        PageHelper.startPage(page, pageSize);

        List<AllzcassetmoveapplyVo> selectmyzcassetmoveList=assetmovelogMapper.selectmyzcassetmoveList(docNo, submitDate, status, proposer);
        return (Page<AllzcassetmoveapplyVo>) selectmyzcassetmoveList;
    }


}
